<script>
	export default {
		onLaunch: function() {
			//#ifdef APP-PLUS  
			var formdata = { 
				//"ver": plus.runtime.version
				"ver": '1.0.0'
			};  
			this.api.request({url:'/api/common/ver',method:'GET',formdata:formdata
			}).then(res=>{
				console.log(res);
				if(res.code==10000){
					uni.showModal({
						title: "更新提示",  
						content: res.msg,  
						success: (res) => {  
							if (res.confirm) {  
								plus.runtime.openURL(res.data.url);  
							}
						}  
					});
				}
			});
			//#endif
			
			//#ifndef H5 || MP-WEIXIN
			const updateManager = uni.getUpdateManager();
			updateManager.onCheckForUpdate(function (res) {
			  // 请求完新版本信息的回调
				if (res.hasUpdate) {
					updateManager.onUpdateReady(function (res2) {
						uni.showModal({
							title: '更新提示',
							content: '新版本已经准备好，是否重启应用？',
							success(res2) {
								if (res2.confirm) {
									updateManager.applyUpdate();
								}
							}
						});
					});
				}
			});
			
			updateManager.onUpdateFailed(function (res) {
				uni.showModal({
					title: '提示',
					content: '检查到有新版本，但下载失败，请检查网络设置',
					success(res) {
						if (res.confirm) {
							updateManager.applyUpdate();
						}
					}
				});
			});
			//#endif
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		}
	}
</script>

<style>
@import url("static/css/c.css");
@import url("static/css/iconfont.css");
	/*每个页面公共css */
.icon{font-size: 60rpx;color: #66AAFF;}
.mhs{color: #FF0000;}
.mhs_b{border-color: #FF0000;}
.mhs_bg{background-color: #FF0000;}
.mhs_bg_active{background-color: #FF0000;color: #FFFFFF;}
.lans{color: #66AAFF;}
.dhuis{color: #f1f1f1;}
.dhuis_b{border-bottom:1px solid #f1f1f1;}
</style>